const http = require('http');
const express = require('express');
const userApi = require('./api/userApi');
const bodyParser = require('body-parser')
let app = express();
let server = http.createServer(app);

app.use(bodyParser.urlencoded({ extended: false }))
// json格式
app.use(bodyParser.json());

// 配置跨域
app.all('*', function (req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With");
    res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
    res.header("X-Powered-By", ' 3.2.1')
    res.header("Content-Type", "application/json;charset=utf-8");
    next();
});
app.use('/api/', userApi);

// 8888端口
server.listen(8888, () => {
    console.log('success! port:8888')
});
